const mongoose = require('mongoose')
const Content = require('../../model/content')
const Reply = require('../../model/reply')

module.exports = async (req, res) => {
    const { id, content, userid } = req.fields
    // console.log(req.fields);
    try {
        const data = await Reply.create({
            content, reply: userid,status:true
        })     
        const result = await Content.updateOne({_id:id},{$push:{
            child:data._id
        }})    
    } catch{
        return res.send({
            data: null,
            meta: {
                status: 401,
                msg: '添加失败'
            }
        })
    }
    res.send({
        data: null,
        meta: {
            status: 201,
            msg: '添加成功'
        }
    })
}